class Goods {
    private String name;
    private int count;
    private double price;
    public  Goods(String name,int count,double price){
    	this.name=name;
    	this.count=count;
    	this.price=price;
    }
    public Goods(String name,double price){
    	this(name,0,price);
    }
    public void setName(String name) {
    	this.name=name;
    }
    public void setCount(int count) {
    	this.count=count;
    }
    public void setPrice(double price) {
    	this.price=price;
    }
    public String getName() {
    	return name;
    }
    public int getCount() {
    	return count;
    }
    public double getPrice() {
    	return price;
    }
    public void buy(int n) {
    	this.count=this.count+n;
    }
    public void sale(int n) {
    	if(n<count)
    		this.count=this.count-n;
        else
        	System.out.println("商品数量不足！！！");
    }
    public void print() {  
        System.out.println("商品名称：" + this.name);  
        System.out.println("商品数量：" + this.count);  
        System.out.println("商品单价：" + this.price);  
    }  
}
public class GoodDemo {
	public static void main(String[] args) {
	     Goods g1=new Goods("超人",5,38.0);
	     g1.buy(5);  
	     System.out.println("进货后：");  
	     g1.print();  
	     g1.sale(3);  
	     System.out.println("销售后：");  
	     g1.print();  
	     g1.sale(15);  
	     System.out.println("尝试销售超过现有数量的商品后：");  
	     g1.print();  
	     } 
}
